// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package pica.ui;

import c;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Vector;
import javax.microedition.lcdui.*;

// Referenced classes of package pica.ui:
//            b, f, h

public final class a extends b
{

    public a(h h, String s1, int i1, int j1, int k1, int l1, TextBox textbox)
    {
        super(h, s1);
        super.e = i1;
        super.f = j1;
        super.g = k1;
        super.h = l1;
        s = textbox;
        d();
    }

    public static void a()
    {
        k = Image.createImage("/middle/emotion.png");
        l = Image.createImage("/middle/card.png");
          goto _L1
        JVM INSTR dup ;
        IOException ioexception;
        ioexception;
        printStackTrace();
_L1:
        m = k.getWidth() / 5;
        n = 2;
        o = m + n + n;
        p = i.length;
        j = new Hashtable((p + p) - 1);
        for(int i1 = p; i1-- > 0;)
            j.put(i[i1], new Integer(i1));

        j.put("(\\s)", new Integer(100));
        j.put("(\\h)", new Integer(101));
        j.put("(\\c)", new Integer(102));
        j.put("(\\d)", new Integer(103));
        return;
    }

    private void d()
    {
        q = super.g / o;
        r = super.h / o;
        v = (super.g - q * o) / 2;
        w = 0;
        t = 0;
    }

    public final void b()
    {
        s.insert(i[t], s.getCaretPosition());
    }

    public final TextBox c()
    {
        return s;
    }

    protected final void a(Graphics g)
    {
        int i1 = super.e + v + n;
        int j1 = super.f + w + n;
        int k1 = u;
        int l1 = 0;
        int i2 = (k1 / 5) * m;
        g.setColor(0xffffff);
        g.fillRect(0, 0, super.b.getWidth(), super.b.getHeight());
        while(k1 < p && j1 < super.f + super.h) 
        {
            g.setClip(i1, j1, m, m);
            g.drawImage(k, i1 - l1, j1 - i2, 20);
            g.setClip(super.e, super.f, super.g, super.h);
            if(k1 == t)
            {
                g.setColor(0xff0000);
                g.drawRect(i1 - 3, j1 - 3, m + 5, m + 5);
            }
            if(++k1 % 5 == 0)
            {
                l1 = 0;
                i2 += m;
            } else
            {
                l1 += m;
            }
            if(k1 % q == 0)
            {
                i1 = super.e + v + n;
                j1 += o;
            } else
            {
                i1 += o;
            }
        }
    }

    protected final boolean a(byte byte0, int i1)
    {
        switch(byte0)
        {
        case 0: // '\0'
            a(i1);
            // fall through

        case 2: // '\002'
        default:
            return true;
        }
    }

    private void a(int i1)
    {
        switch(i1)
        {
        default:
            break;

        case -1: 
        case 50: // '2'
            if(t >= q)
            {
                t -= q;
                if(t < u)
                {
                    u -= q;
                    return;
                }
            }
            break;

        case -2: 
        case 56: // '8'
            if(t >= p - q)
                break;
            t += q;
            if(t - u >= r * q)
            {
                u += q;
                return;
            }
            break;

        case -3: 
        case 52: // '4'
            if(t <= 0)
                break;
            t--;
            if(t < u)
            {
                u -= q;
                return;
            }
            break;

        case -4: 
        case 54: // '6'
            if(t >= p - 1)
                break;
            t++;
            if(t - u >= r * q)
            {
                u += q;
                return;
            }
            break;

        case -5: 
        case 53: // '5'
            super.a.a(15, s);
            return;
        }
    }

    protected final boolean a(byte byte0, int i1, int j1)
    {
        if(byte0 == 0)
            return a(i1, j1);
        else
            return false;
    }

    private boolean a(int i1, int j1)
    {
        if(f.a(i1, j1, super.e + v, super.f + w, super.g, super.h))
        {
            int k1 = (j1 - super.f - w) / o;
            int l1 = (i1 - super.e - v) / o;
            int i2;
            if((i2 = k1 * q + l1) >= p)
            {
                return false;
            } else
            {
                t = i2;
                a(-5);
                return true;
            }
        } else
        {
            return false;
        }
    }

    public static Vector a(String s1, int i1, Font font, boolean flag)
    {
        if(s1 == null || s1.length() == 0)
            return new Vector();
        Vector vector = flag ? null : new Vector();
        Vector vector1 = new Vector();
        int j1 = s1.length();
        char ac[] = s1.toCharArray();
        int k1 = 0;
        int l1 = 0;
        int i2 = 0;
        Integer integer = null;
        int j2 = 1;
        boolean flag1 = false;
        while(i2 < j1 - 1) 
        {
            Object obj;
            switch(ac[i2])
            {
            case 10: // '\n'
                integer = new Integer(-1);
                flag1 = true;
                j2 = 1;
                break;

            case 40: // '('
                if(i2 < j1 - 2)
                {
                    int k2 = i2 + 2;
                    do
                    {
                        if(k2 >= i2 + 6 || k2 == j1)
                            break;
                        if(ac[k2] == ')')
                        {
                            Object obj1;
                            if((obj1 = j.get(new String(ac, i2, (k2 + 1) - i2))) != null)
                            {
                                integer = (Integer)obj1;
                                flag1 = true;
                                j2 = (k2 + 1) - i2;
                            }
                            break;
                        }
                        k2++;
                    } while(true);
                }
                break;

            case 58: // ':'
                if(ac[i2 + 1] == '\'' && i2 < j1 - 2 && ac[i2 + 2] == '(')
                {
                    integer = new Integer(15);
                    flag1 = true;
                    j2 = 3;
                } else
                if(ac[i2 + 1] == '-' && i2 < j1 - 2 && ac[i2 + 2] == 'o')
                {
                    integer = new Integer(12);
                    flag1 = true;
                    j2 = 3;
                } else
                if((obj = j.get(new String(ac, i2, 2))) != null)
                {
                    integer = (Integer)obj;
                    flag1 = true;
                    j2 = 2;
                }
                break;

            default:
                if(i2 < j1 - 2 && (obj = j.get(new String(ac, i2, 3))) != null)
                {
                    integer = (Integer)obj;
                    flag1 = true;
                    j2 = 3;
                }
                break;
            }
            if(flag1)
            {
                if(i2 > l1)
                    vector1.addElement(new String(ac, l1, i2 - l1));
                if(integer.intValue() == -1)
                {
                    if(flag)
                        return vector1;
                    vector.addElement(vector1);
                    vector1 = new Vector();
                    k1 = 0;
                } else
                {
                    if(k1 + m > i1)
                    {
                        if(flag)
                            return vector1;
                        vector.addElement(vector1);
                        vector1 = new Vector();
                        k1 = 0;
                    }
                    vector1.addElement(integer);
                    k1 += m;
                }
                l1 = i2 += j2;
                flag1 = false;
                j2 = 1;
            } else
            {
                if((k1 += font.charWidth(ac[i2])) > i1)
                {
                    vector1.addElement(new String(ac, l1, i2 - l1));
                    if(flag)
                        return vector1;
                    vector.addElement(vector1);
                    vector1 = new Vector();
                    l1 = i2;
                    k1 = font.charWidth(ac[i2]);
                }
                i2++;
            }
        }
        if((i2 = j1) > l1)
            vector1.addElement(new String(ac, l1, i2 - l1));
        if(flag)
            return vector1;
        if(vector1.size() > 0)
            vector.addElement(vector1);
        return vector;
    }

    public static void a(boolean flag)
    {
        z = flag;
    }

    public static void a(Graphics g, String s1, int i1, int j1, int k1, int l1)
    {
        int i2 = g.getClipX();
        int j2 = g.getClipY();
        int k2 = g.getClipWidth();
        int l2 = g.getClipHeight();
        int i3 = l1 - i1;
        g.setClip(i1, j2, i3, l2);
        if(z)
        {
            if(s1 == A)
            {
                if(C > i3)
                    if(C - x < i3)
                    {
                        if(y++ > 10)
                        {
                            x = 0;
                            y = 0;
                        }
                    } else
                    {
                        x += 2;
                    }
            } else
            {
                x = 0;
                y = 0;
                A = s1;
                B = a(s1, g.getFont().stringWidth(s1) * 2, g.getFont(), true);
                C = a(B, g);
            }
            a(g, B, i1 - x, j1, k1);
        } else
        {
            Vector vector = a(s1, i3, g.getFont(), true);
            a(g, vector, i1, j1, k1);
        }
        g.setClip(i2, j2, k2, l2);
    }

    private static int a(Vector vector, Graphics g)
    {
        int i1 = 0;
        Object obj = null;
        for(int j1 = 0; j1 < vector.size(); j1++)
        {
            Object obj1;
            if((obj1 = vector.elementAt(j1)) instanceof String)
                i1 += g.getFont().stringWidth((String)obj1);
            else
                i1 += 18;
        }

        return i1;
    }

    public static void a(Graphics g, Vector vector, int i1, int j1, int k1)
    {
        int l1 = g.getClipX();
        int i2 = g.getClipY();
        int j2 = g.getClipWidth();
        int k2 = g.getClipHeight();
        int l2 = i1;
        int i3 = 0;
        int j3 = 0;
        if((k1 & 4) != 0)
            i3 = 0;
        else
        if((k1 & 1) != 0)
            i3 = m / 2;
        else
        if((k1 & 8) != 0)
            i3 = m;
        if((k1 & 0x10) != 0)
            j3 = (18 - g.getFont().getHeight()) / 2;
        else
        if((k1 & 0x40) != 0)
            j3 = m / 2;
        else
        if((k1 & 0x20) != 0)
            j3 = m;
        for(int k3 = 0; k3 < vector.size(); k3++)
        {
            Object obj;
            if((obj = vector.elementAt(k3)) instanceof String)
            {
                String s1 = (String)obj;
                g.drawString(s1, l2, j1, k1);
                l2 += g.getFont().stringWidth(s1);
                continue;
            }
            int l3;
            if((l3 = l2 - i3) > l1 - m && l3 < l1 + j2)
            {
                if(l3 < l1)
                    g.setClip(l1, j1 - j3, (l3 + m) - l1, m);
                else
                if(l3 + m > l1 + j2)
                    g.setClip(l3, j1 - j3, (l1 + j2) - l3, m);
                else
                    g.setClip(l3, j1 - j3, m, m);
                int i4;
                if((i4 = ((Integer)obj).intValue()) >= 100)
                {
                    i4 -= 100;
                    g.drawImage(l, l3 - i4 * m, j1 - j3, 20);
                } else
                {
                    g.drawImage(k, l3 - (i4 % 5) * m, j1 - j3 - (i4 / 5) * m, 20);
                }
                g.setClip(l1, i2, j2, k2);
            }
            l2 += m;
        }

    }

    private static final String i[] = {
        ":)", ":D", ":P", ":$", "(SX)", "*-)", "(EN)", "(SL)", ":|", ":(", 
        ":S", "(H)", ":-o", "(JX)", "(a`)", ":'(", "(6)", ":@", "(Y)", "(N)", 
        "(TU)", "(HS)", "P(:", "{k}", "^o)", "(:-#)", "|-)", "(GD)", "+o(", "(886)", 
        "(K)", "(L)", "(Ss)", "(F)", "(W)", "(mo)", "(0)", "(pi)", "(Bomb)", "(h5)"
    };
    private static Hashtable j;
    private static Image k;
    private static Image l;
    private static int m;
    private static int n;
    private static int o;
    private static int p;
    private static int q;
    private static int r;
    private TextBox s;
    private int t;
    private int u;
    private static int v;
    private static int w;
    private static int x;
    private static int y;
    private static boolean z;
    private static String A;
    private static Vector B;
    private static int C;

}
